<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="Idiv">
    <span>
    <a href="">我是光！！！迪迦</a>
</span>l
</div>
<hr>
<input type="button" id="b1" value="得到html">
<input type="button" id="b2" value="设置html">
<input type="button" id="b3" value="得到text">
<input type="button" id="b4" value="设置html">
</body>
</html>
<script type="text/javascript">
    document.getElementById("b1").onclick = function (ev) {
        alert(document.getElementById("Idiv").innerHTML);
    };
    document.getElementById("b2").onclick = function (ev) {
        document.getElementById("Idiv").innerHTML= "<h2 style='color: red'>我是标题</h2>"
    }
    document.getElementById("b3").onclick = function (ev) {
        alert(document.getElementById("Idiv").innerText);
    }
    document.getElementById("b4").onclick = function (ev) {
        document.getElementById("Idiv").innerText= "<h2 style='color: red'>我是标题</h2>"
    }
</script>
